package org.zjx.test.tasks;

import org.zjx.task.AbstractTask;
import org.zjx.context.ChainContext;
import org.zjx.task.core.TaskScheduler;

public class DemoTask extends AbstractTask {
    private boolean shouldFail;

    public DemoTask() {
        super("demoTask");
    }
    @Override
    public void execute(ChainContext context, TaskScheduler scheduler) throws Exception {
        boolean shouldFail = Boolean.TRUE.equals(params.get("shouldFail"));

        if (shouldFail) {
            shouldFail = false;
            throw new Exception("DemoTask failed");
        }
        System.out.println(getTaskId() + " executed successfully.");
    }
}
